﻿using CaffeeBuzz_WinForm.Cafe;
using CaffeeBuzz_WinForm.BuzzMenu;
using CaffeeBuzz_WinForm.Shared;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CaffeeBuzz_WinForm.Commands
{
    class FoodCommand:Command
    {
        
        List<Menu> menus;
        int _iMenu = -1;

        public FoodCommand()
        {
            menus = new List<Menu>();
            menus.Add(new BreakfastMenu());
            menus.Add(new LunchMenu());
        }
        public int iMenu
        {
            get { return _iMenu; }
            set 
            {
                if (0 <= _iMenu && _iMenu < menus.Count)
                    _iMenu = value;
            }
        }
        public List<Menu> Menus
        {
            get { return menus; }
            set { menus = value; }
        }
        public FoodCommand(List<Menu> menus)
        {
            this.menus = menus;
        }
        public double Cost()
        {
            return menus[_iMenu].Price;
        }
        public string GetName()
        {
            return "Food Menu";
        }
        public List<Item> GetAllItem()
        {
            Menu menu = menus[_iMenu];
            List<Item> l = new List<Item>();
            Iterator iterator = menu.CreateIterator();
            while (iterator.HasNext())
            {
                Item i = (Item)iterator.Next();
                l.Add(i);
            }
            return l;
        }
        public Item GetItem(int index)
        {
            List<Item> l = GetAllItem();
            if (0 <= index && index < l.Count)
                return l[index];
            return null;
        }
        public void LoadFromFile(string FileName)
        {
            throw new NotImplementedException();
        }


       
    }
}
